package com.example.Blog.controller;

import com.example.Blog.service.ArticleTypeService;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/articleType")
public class ArticleTypeController {
    final ArticleTypeService articleTypeService;
    public ArticleTypeController(ArticleTypeService articleTypeService){
        this.articleTypeService = articleTypeService;
    }
    @GetMapping("/add")
    @ResponseBody
    public String add(@Param("articleType") String articleType){
        if(this.articleTypeService.add(articleType))
            return "success";
        return "fail";
    }

    @GetMapping("delete")
    @ResponseBody
    public String delete(@Param("articleType") String articleType){
        if(this.articleTypeService.delete(articleType))
            return "success";
        return "fail";
    }
}
